package com.grj.park.common;

import lombok.Data;

@Data
public class R<T> {

    private Integer code;
    private String msg;
    private T data;

    private R(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> R<T> ok() {
        return new R<>(200, "", null);
    }

    public static <T> R<T> ok(T data) {
        return new R<>(200, "", data);
    }

    public static <T> R<T> ok(String msg, T data) {
        return new R<>(200, msg, data);
    }

    public static <T> R<T> okMsg(String msg) {
        return new R<>(200, msg, null);
    }
    public static <T> R<T> fail(String msg) {
        return new R<>(500, msg, null);
    }
    public static <T> R<T> fail(Integer code, String msg) {
        return new R<>(code, msg, null);
    }
    public static <T> R<T> fail(Integer code, String msg, T data) {
        return new R<>(code, msg, data);
    }
    public static <T> R<T> fail(String msg, T data) {
        return new R<>(500, msg, data);
    }
    public static <T> R<T> fail() {
        return new R<>(500, "fail", null);
    }
    public static <T> R<T> fail(Integer code) {
        return new R<>(code, "fail", null);
    }
}
